package is2.minga.packetProcessor;

import java.io.PrintWriter;
import java.net.Socket;

import is2.misc.pipeAndFilter.InPipeConnector;


public class OutPacketProcessor implements Runnable
{
	private InPipeConnector<String> pipe;
	private Integer port;
	private String host;
	
	public OutPacketProcessor(InPipeConnector<String> pipe, String host, Integer port)
	{
		this.pipe = pipe;
		this.port = port;
		
	}

	
	public void run()
	{
		
		while (true)
		{
			
			try {
				
				String msg = pipe.Take();
				System.out.println("salida del modulo minga: " + msg );
				Socket clientSocket = new Socket(host, port); 
				PrintWriter out;
	
				out = new PrintWriter(clientSocket.getOutputStream(), true);
				out.println(msg);
				
		
	
			} catch (Exception e) {
				System.err.println( "error en outpacketprocessor");
				System.err.println( e.toString());
			} 
	
		}		
		
		
	}
	
	
	
}
